<?
// handle errors
handle_error($errors);
?>
<!DOCTYPE HTML><html>
<head>
<? echo $h->meta($title, $kwd, $dpn); ?>
<? require_once("lib.php"); ?>
<script src="<?=$ecom?>/js/jquery.validate.js" type="text/javascript"></script>
<script src="<?=$ecom?>/js/jquery.metadata.js" type="text/javascript"></script>
</head>

<body>
<? include_once("header.php"); ?>
<div id="wrap">
	<div id="main">
		<ul class="flow_step">
			<li>...</li>
			<li class="step1"><?=$order_status?></li>
			<li>...</li>
		<div class="clear"></div>
		</ul><!--flow_step end -->
		<? 
		// 若有实体商品, 加载之
		if(! $are_virtual){
		?>
		<div id="addr_box">
			<div id="order_title"><?=WEB_ADDRESS_BOOK?></div>
			<ul class="order_address_list">
				<?
					$tem_province=$province->get_name($info['province'],$lang);
					$tem_addr=$tem_province;
					if(! empty($info['city'])) { $tem_city=$city->get_name($info['city'],$lang); $tem_addr.=$tem_city.'/'; }
					if(! empty($info['county'])) { $tem_county=$county->get_name($info['county'],$lang); $tem_addr.=$tem_county.'/'; }
					$tem_addr.=' '.$info['address'].', &nbsp; '.$info['contact_name'].' '.$info['mobile'];
				?>
				<li class="  selected  delete4">
				<div class="order_address_info">
					<span class="c1 radio_wrap"><input checked  id="radio4" type="radio" name="address_id"></input></span>
					<label class="radio_desp" for="radio4">
					<span class="c3"> &nbsp; <?=$tem_addr?></span></label>
				</div>
				<div class="clear"></div>
				</li>
				</ul>
		</div><!--addr_box end-->
		<? } else { ?>
		<div id="addr_box">
			<div id="order_title"><?=WEB_ADDRESS_BOOK?></div>
			<ul class="order_address_list">
				<li class="  selected  delete4">
				<div class="order_address_info">
					<span class="c1 radio_wrap"><input checked  id="radio4" type="radio" name="address_id"></input></span>
					<label class="radio_desp" for="radio4">
					<span class="c3"> &nbsp; <?=$info['contact_name'].' '.$info['mobile']?></span></label>
				</div>
				<div class="clear"></div>
				</li>
				</ul>
		</div><!--addr_box end-->
		<? } ?>
		<div id="pay_box">
			<div id="order_title"><?=WEB_PAYMENT_METHOD?></div>
			<div class="order_payment_area">
				<ul class="payment_bank_list">
					<?
						$str=''; $k==0;
						foreach($arr_payment as $key=>$row){
							$checked='';
							if($k==0)$checked=' checked ';
							$str.='<li>
						<div class="payment_area"><input checked id="pay_'.$k.'" class="radio" type="radio" name="payment_method" value="'.$row['id'].'"></input>
							<label class="vam" for="pay_'.$k.'">';

							if(empty($row['pic']))$str.=$row['name_'.$lang];
							else $str.='<img src="upload/'.$row['pic'].'" height="36" />';

							$str.='</label>
						</div>
					</li>';
							$k++;
						}
						echo $str;
					?>
				</ul><!--payment_bank_list end--><div class="clear"></div>
				<?
				// 在线付款方式, 成功付款后显示单据
				if($payment_method_id!=5 && $payment_method_id!=6 && $order_status_id>2 && $order_status_id<6){?>
				<table class="receipt" width="100%">
						<tr><td width="120" class="tright"><?=WEB_PAYMENT_REF_NO?>:</td><td><?=$info['payment_ref_no']?></td></tr>
						<tr><td class="tright"><?=WEB_PAYER?>:</td><td><?=$info['payer']?></td></tr>
						<tr class="hide"><td class="tright"><?=WEB_PAYER_ID?>:</td><td><?=$info['payer_id']?></td></tr>
						<tr><td class="tright"><?=WEB_UPDATE_TIME?>:</td><td><?=$info['paid_time']?></td></tr>
					</table>
				<? }
				// 银行转账方式, 单据处理
				if($payment_method_id==6){
					if($order_status_id<3){
					echo $h->form('old_order.php',1,'need_check');
					echo $h->hidden('action','update');
					echo $h->hidden('ref_no',$ref_no);
					$receipt_button=' '.WEB_SUBMIT.' ';
					$not_first_time=0;
				?>
					<table class="receipt">
						<tr><td width="160" class="tright"><span class="red">*</span> <?=WEB_BANK_REF_NO?>:</td><td>
							<? if($info['payment_ref_no'] != '') { echo $info['payment_ref_no']; $not_first_time=1; }  else { ?>
							<input name="payment_ref_no" class="g {validate:{required:true,messages:{required:'<?=WEB_REQUIRED?>'}}}" />
						<? } ?>
						</td></tr>
						<tr><td class="tright"><span class="red">*</span> <?=WEB_BANK_ACCOUNT?>:</td><td>
							<? if($info['payer_id'] != '') { echo $info['payer_id']; $not_first_time=1; }  else { ?>
							<input name="payer_id" class="g {validate:{required:true,messages:{required:'<?=WEB_REQUIRED?>'}}}" />
							<? } ?>
						</td></tr>
						<tr><td class="tright"><span class="red">*</span> <?=WEB_BANK_ACCOUNT_OWNER?>:</td><td>
							<? if($info['payer'] != '') { echo $info['payer']; $not_first_time=1; } else { ?>
							<input name="payer" class="g {validate:{required:true,messages:{required:'<?=WEB_REQUIRED?>'}}}" />
							<?  } ?>
						</td></tr>
						<tr><td class="tright"><?=WEB_BANK_RECEIPT?>:</td><td>
							<? if($info['receipt_doc'] != ''){ ?>
							<a href="upload/<?=$info['receipt_doc']?>" target="_blank"><img src="upload/<?=$info['receipt_doc']?>" height="120" /></a><br />
							<? } ?>
							<? echo $h->cfile('cpic', 'g');
							if($not_first_time==1) $receipt_button=' '.WEB_UPDATE.' ';
							?></td></tr>
						<tr><td>&nbsp;</td><td><a class="button_blue" onclick="$('.need_check').submit();"><?=$receipt_button?></a></td></tr>
					</table>
					<? echo $h->former(); ?>
				<script type="text/javascript">
				$(document).ready(function(){
					$(".need_check").validate({meta: "validate", onkeyup: false, 
						errorPlacement: function( label, element ) {
							element.parent().append("<br>").append(label);
						}
					});
				}	);
				</script>
				<? }
					if( $order_status_id>2 && $order_status_id<6) { ?>
					<table class="receipt" width="100%">
						<tr><td width="120" class="tright"><?=WEB_BANK_REF_NO?>:</td><td><?=$info['payment_ref_no']?></td></tr>
						<tr><td class="tright"><?=WEB_BANK_ACCOUNT?>:</td><td><?=$info['payer_id']?></td></tr>
						<tr><td class="tright"><?=WEB_BANK_ACCOUNT_OWNER?>:</td><td><?=$info['payer']?></td></tr>
						<tr><td class="tright"><?=WEB_UPDATE_TIME?>:</td><td><?=$info['paid_time']?></td></tr>
						<tr><td class="tright"><?=WEB_BANK_RECEIPT?>:</td><td>
							<? if($info['receipt_doc'] != ''){ ?>
							<a href="upload/<?=$info['receipt_doc']?>" target="_blank"><img src="upload/<?=$info['receipt_doc']?>" height="120" /></a>
							<? } else echo WEB_NO_SUCH_DATA; ?>
						</td></tr>
					</table>
				<? }
				}
				 ?>
			</div><!--order_payment_area end-->

		</div><!--pay_box end-->
		<?
			$tem_hide=' hide ';
			if(! empty($info['invoice_header'])) $tem_hide='';
		?>
		<div id="pay_box" class="<?=$tem_hide?>">
			<div id="order_title"><?=WEB_INVOICE_INFO?></div>
			<div class="order_invoice_area">
				<table border="0" cellpadding="0" cellspacing="0">
            		<tbody>
                	<tr class="invoicer <?=$tem_invoice_hide?>">
            		<td><label class="vam" for="titleType-com"><?=WEB_INVOICE_HEADER?>: </label>&nbsp;&nbsp;
					<div class="inline-block"><?=$info['invoice_header'] ?></div></td>
                    	</tr>
                	</tbody>
            	</table>
			</div><!--order_invoice_area end-->
		</div><!--pay_box end-->
		<? 
		// 若有实体商品, 加载之
		if(! $are_virtual){
		?>
		<div id="pay_box">
			<div id="order_title"><?=WEB_SHIPMENT_METHOD?></div>
			<ul class="delivery_list">
				<?
				$str='';
				$k=0;
				foreach($arr_shipment as $row){
					$checked='';
					if($k==0)$checked=' checked ';
					$str.='<li>
				<div class="payment_area shipment'.$k.'"><input onclick="cal_price('.$k.')" '.$checked.' id="shipment_'.$k.'" class="radio" type="radio" name="shipment_method" value="'.$row['id'].'" />
					<label class="vam" for="shipment_'.$k.'">'.$row['name_'.$lang].'<span class="vam gray">'.WEB_SHIPMENT_FEE.' &nbsp; '.$order_currency_sign.'<em class="a_shipment_cost">'.$info['shipment_cost'].'</em></label>
					</div>
				</li>';
					$k++;
				}
				echo $str;
			?>
			</ul>
			<div class="clear"></div>
			<? if($order_status_id>3 && $order_status_id<6){
				$tem_shipment_company=$arr_shipment[$info['shipment_method_id']]['name_'.$lang];
				$tem_shipment_code=$info['shipment_tracking_no'];
				$tem_shipment_url=$arr_shipment[$info['shipment_method_id']]['tracking_url'];
				$tem_shipment_time=$info['shipped_time'];
			?>
				<table class="receipt" width="100%">
					<tr><td width="120" class="tright"><?=WEB_SHIPMENT_METHOD?>:</td><td><?=$tem_shipment_company?></td></tr>
					<tr><td class="tright"><?=WEB_SHIPMENT_TIME?>:</td><td><?=$tem_shipment_time?></td></tr>
					<tr><td class="tright"><?=WEB_TRACK_NO?>:</td><td><?=$tem_shipment_code?></td></tr>
					<tr><td class="tright"><?=WEB_TRACK_URL?>:</td><td><a target="_blank" class="blue" href="<?=$tem_shipment_url?>"><?=$tem_shipment_url?></a></td></tr>
				</table>
			<? } ?>
            <div class="tright hide"><br /><span class="icon-over vam">买满200元免运费. &nbsp; </span></div>
		</div><!--pay_box end-->
		<? } ?>
		<?	echo $h->form('old_order_checkout.php',0,'order_form');
			$key=md5('ecomgear'.date('Ymd'));
			echo $h->hidden('key',$key);
			// 表单 - 地址部分
		?>
		<div id="pay_box">
			<div id="order_title"><?=WEB_ITEM_LIST?></div>
			<table class="table_cart" cellpadding="0" cellspacing="0">
			<thead class="list_cart">
				<tr>
				<th class="textcenter" width="360"><?=WEB_ITEM?></th>
				<th><?=WEB_UNIT_PRICE?></th>
				<th><?=WEB_QTY?></th>
				<th><?=WEB_SUBTOTAL?></th>
				</tr>
			</thead>
			<tbody>
			<?	$str='';
				$order_price=0;
				foreach($arr_cart as $row){
					$tem_product=$product->get_row($row['pid']);
					$tem_pic=$tem_product['small_pic'];
					$tem_link='product-'.$row['pid'].'.html';
					$tem_name=$tem_product['name_'.$lang];
					$tem_price=$row['unit_price'];
					$tem_qty=$row['qty'];
					$tem_total=$tem_qty*$tem_price;
					$order_price+=$tem_total;

					// variation
					$str_var='';
					$tem_var=$product_variation->get_row($row['var']);
					if($tem_var['size']) $str_var.=$option_label[2].': '.$option_value[$tem_var['size']].' &nbsp; ';
					if($tem_var['color']) $str_var.=$option_label[1].': '.$option_value[$tem_var['color']].' &nbsp; ';
					if($tem_var['other1']) $str_var.=$option_label[3].': '.$option_value[$tem_var['other1']].' &nbsp; ';
					if($tem_var['other2']) $str_var.=$option_label[4].': '.$option_value[$tem_var['other2']].' &nbsp; ';
					
					$str.='<tr>
				<td><div class="goods"><span class="image"><a href="'.$tem_link.'" target="_blank"><img src="'.PRODUCT_PIC_HOST.$tem_pic.'"/></a></span><div class="name"><a href="'.$tem_link.'" target="_blank">'.$tem_name.'</a><br /><br /><span class="gray">'.$str_var.'</span></div><div class="clear"></div></div></td>
				<td><strong class="price red">'.$order_currency_sign.' '.$tem_price.'</strong></td>
				<td>'.$tem_qty.'</td>
				<td><strong class="price">'.$order_currency_sign.' '.$tem_total.'</strong></td>
				</tr>';
				}
				echo $str;
			?>
			</tbody>
			<?
				// 表单 - 金额部分
				$shipment_fee=$info['shipment_cost'];
				$total_price=$info['total_price'];
				echo $h->hidden('total_price',$total_price,'total_price');
				echo $h->hidden('currency_code',$order_currency_code,'currency_sign');
				echo $h->hidden('ref_no',$ref_no,'ref_no');
				echo $h->hidden('payment_method_id',$info['payment_method_id'],'payment_method_id');
			?>
			<tfoot>
				<tr>
				<th colspan="4">
					<div class="customer_remark">
						<div><?=WEB_ORDER_REMARK?>: &nbsp; <?=empty($info['customer_remark'])?'-':$info['customer_remark']; ?></div>
					</div>
					<div class="price_check_box inherit">
						<div class="price_list">
							<div class="total">
							<p><span class="t"><?=WEB_TOTAL_FOR_ITEMS?>：</span><span class="txt price"><? echo $order_currency_sign.' '.$order_price ?></span></p>
							<? $nada=''; if($are_virtual) $nada=' class="hide" '; ?>
							<p <?=$nada?>><span class="t"><?=WEB_SHIPMENT_FEE?>：</span><span class="txt price"><? echo $order_currency_sign.'<span class="span_shipment_cost">'.$shipment_fee.'</span>' ?></span></p>
							<? $nada=''; if(! $info['with_tax']) $nada=' class="hide" '; ?>
							<p id="div_tax"  <?=$nada?>><span class="t"><?=WEB_TAX?>：</span><span class="txt price"><? echo $order_currency_sign.' <span class="span_tax">'.$info['tax'].'</span>' ?></span></p>
							<p><span class="t all"><?=WEB_ORDER_TOTAL?>：</span> <span class="txt finalprice"><? echo $order_currency_sign.' <span class="span_total_price">'.$total_price.'</span>'; ?></span></p>
							</div>
							<? 
								$hide='hide';
								if($can_pay_online) $hide='';
							?>
							<div class="cart_buttom <?=$hide?>">
								<a class="payment" onclick="order_submit()"><?=WEB_ORDER_GOON?></a>
							</div>
						</div>
					<div class="clear"></div>
					</div>
				</th>
				</tr>
			</tfoot>
		</table>
		</div><!--pay_box end-->
		<? echo $h->former(); ?>
	</div><!--main end-->
</div><!--wrap end-->
<? include("footer.php"); ?>
</body>
</html>